/*--------------------------文本框→（手机号码&验证码）--------------------------*/

/*点击文本框“默认字体”消失*/
function disappear1(){
	var text1=document.getElementById("phoneNum");
	text1.value="";
	var tips_phone=document.getElementById("tips_phone");
	tips_phone.style.opacity="0";
	tips_phone.style.filter="Alpha(opacity=0)";
}
function disappear2(){
	var text2=document.getElementById("Verification");
	text2.value="";
}
/*点击文本框外围“默认字体”出现*/
function appear1(){
	var text3=document.getElementById("phoneNum");
	var tips_phone=document.getElementById("tips_phone");
	if(text3.value==""){
			text3.value="请输入手机号";
	}
	
	var phoneLen=text3.value.length;
	if(text3.value!="请输入手机号")
	{
	if(phoneLen!=11)
	{
		tips_phone.style.opacity="1";
		tips_phone.style.filter="Alpha(opacity=100)";
	}
	for(var i=0;i<phoneLen;i++)
	{
		var c=text3.value.charAt(i);
		if(c<"0"||c>"9")
		{
			tips_phone.style.opacity="1";
			tips_phone.style.filter="Alpha(opacity=100)";
		}
		
	}
	}	
}
function appear2(){
	var text4=document.getElementById("Verification");
	if(text4.value==""){
			text4.value="获取验证码";
	}
}

/*--------------------------文本框→（选择学校&选择年级&选择班级）--------------------------*/
function changeSpan1(sth,span,strstr){
	var sth=document.getElementById(sth);
	var span=document.getElementById(span);
	var sthName=sth.options[sth.options.selectedIndex].text;
	var str="...";
	if(sthName.indexOf(str)==-1)
	{span.innerHTML=sthName;}
	else
	{
		span.innerHTML="请选择"+strstr;
		
	}
	
	var grade=document.getElementById("grade");
	var gradeName;
	var gradeLen=first_grade.length;
	var Class=document.getElementById("class");
	var i;
	
	
	
		if(sthName==first_grade[1])
		{
			Class.options.length=0;
			for(i=0;i<first_class.length;i++)
			{
			var theName=first_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[2])
		{
			Class.options.length=0;
			for(i=0;i<second_class.length;i++)
			{
			var theName=second_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[3])
		{
			Class.options.length=0;
			for(i=0;i<third_class.length;i++)
			{
			var theName=third_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[4])
		{
			Class.options.length=0;
			for(i=0;i<forth_class.length;i++)
			{
			var theName=forth_class[i];
			Class.options.add(new Option(theName,i));
			}
		}

	
	
}

/*--------------------------数组--------------------------*/
var first_class=new Array();/*大四*/
first_class[0]="请选择班级...";
first_class[1]="12软件1班";
first_class[2]="12软件2班";
first_class[3]="12软件3班";
first_class[4]="12软件4班";
var second_class=new Array();/*大三*/
second_class[0]="请选择班级...";
second_class[1]="13软件1班";
second_class[2]="13软件2班";
second_class[3]="13软件3班";
var third_class=new Array();/*大二*/
third_class[0]="请选择班级...";
third_class[1]="14软件1班";
third_class[2]="14软件2班";
third_class[3]="14软件3班";
var forth_class=new Array();/*大一*/
forth_class[0]="请选择班级...";
forth_class[1]="15软件1班";
forth_class[2]="15软件2班";
forth_class[3]="15软件3班";

var first_grade=new Array();/*大四*/
first_grade[0]="请选择年级...";
first_grade[1]="2012";
first_grade[2]="2013";
first_grade[3]="2014";
first_grade[4]="2015";

/*onload*/
function openpage(){
	var grade=document.getElementById("grade");
	
	for(var p=0;p<first_grade.length;p++)
	{
		var firstgrade=first_grade[p];
		grade.options.add(new Option(firstgrade,p));
	}
}
/*--------------------------按钮的改变→（验证码&登录）--------------------------*/

/*获取验证码按钮*/
/*获取验证码按钮*/
var countdown=60;
/*--------------------------文本框→（手机号码&验证码）--------------------------*/

/*点击文本框“默认字体”消失*/
function disappear1(){
	var text1=document.getElementById("phoneNum");
	text1.value="";
	var tips_phone=document.getElementById("tips_phone");
	tips_phone.style.opacity="0";
	tips_phone.style.filter="Alpha(opacity=0)";
}
function disappear2(){
	var text2=document.getElementById("Verification");
	text2.value="";
}
/*点击文本框外围“默认字体”出现*/
function appear1(){
	var text3=document.getElementById("phoneNum");
	var tips_phone=document.getElementById("tips_phone");
	if(text3.value==""){
			text3.value="请输入手机号";
	}
	
	var phoneLen=text3.value.length;
	if(text3.value!="请输入手机号")
	{
	if(phoneLen!=11)
	{
		tips_phone.style.opacity="1";
		tips_phone.style.filter="Alpha(opacity=100)";
	}
	for(var i=0;i<phoneLen;i++)
	{
		var c=text3.value.charAt(i);
		if(c<"0"||c>"9")
		{
			tips_phone.style.opacity="1";
			tips_phone.style.filter="Alpha(opacity=100)";
		}
		
	}
	}	
}
function appear2(){
	var text4=document.getElementById("Verification");
	if(text4.value==""){
			text4.value="获取验证码";
	}
}

/*--------------------------文本框→（选择学校&选择年级&选择班级）--------------------------*/
function changeSpan1(sth,span,strstr){
	var sth=document.getElementById(sth);
	var span=document.getElementById(span);
	var sthName=sth.options[sth.options.selectedIndex].text;
	var str="...";
	if(sthName.indexOf(str)==-1)
	{span.innerHTML=sthName;}
	else
	{
		span.innerHTML="请选择"+strstr;
		
	}
	
	var grade=document.getElementById("grade");
	var gradeName;
	var gradeLen=first_grade.length;
	var Class=document.getElementById("class");
	var i;
	
	
	
		if(sthName==first_grade[1])
		{
			Class.options.length=0;
			for(i=0;i<first_class.length;i++)
			{
			var theName=first_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[2])
		{
			Class.options.length=0;
			for(i=0;i<second_class.length;i++)
			{
			var theName=second_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[3])
		{
			Class.options.length=0;
			for(i=0;i<third_class.length;i++)
			{
			var theName=third_class[i];
			Class.options.add(new Option(theName,i));
			}
		}
		else if(sthName==first_grade[4])
		{
			Class.options.length=0;
			for(i=0;i<forth_class.length;i++)
			{
			var theName=forth_class[i];
			Class.options.add(new Option(theName,i));
			}
		}

	
	
}

/*onload*/
function openpage(){
	var grade=document.getElementById("grade");
	
	for(var p=0;p<first_grade.length;p++)
	{
		var firstgrade=first_grade[p];
		grade.options.add(new Option(firstgrade,p));
	}
}
/*--------------------------按钮的改变→（验证码&登录）--------------------------*/

/*获取验证码按钮*/
var countdown=60;
function changeVerification_button()
{
	var buttonVerification=document.getElementById("button_Verification");
	var buttonVerification1=document.getElementById("button_Verification1");
	var new1=document.getElementById("new1");
	var new2=document.getElementById("new2");
	var phoneNum=document.getElementById("phoneNum");
	var tipPhone=document.getElementById("tips_phone");

	if(phoneNum.value=="请输入手机号"||tipPhone.style.opacity=="1")
	{
		alert("请输入正确的手机号码再获取验证码！");
		return;
	}
	 
		if (countdown == 0) {
            buttonVerification.removeAttribute("disabled");
            new1.style.display="block";
            new2.style.display="none";
           buttonVerification.innerHTML="获取验证码";
            countdown = 60;
           
        } else { 
            buttonVerification1.setAttribute("disabled", true);
            new1.style.display="none";
            new2.style.display="block";
            buttonVerification1.innerHTML="重新发送(" + countdown + ")";
            
            countdown--;
            setTimeout(function() {
                changeVerification_button(buttonVerification)
            },
            1000)   
          }
}

/*登录按钮*/
function changeLogin(){
	var new3=document.getElementById("new3");
	var new4=document.getElementById("new4");
	
	var tipPhone=document.getElementById("tips_phone");
	var tipVer=document.getElementById("tips_Verification");
	
	
	/*---判断---*/
	var span1=document.getElementById("span1");
	var span2=document.getElementById("span2");
	var span3=document.getElementById("span3");
	var phoneNum=document.getElementById("phoneNum");
	var Verification=document.getElementById("Verification");
	
	if(span1.innerText=="请选择学院"||span2.innerText=="请选择年级"||span3.innerText=="请选择班级")
	{
		alert("选项不得为空！");
	}
	else if(phoneNum.value=="请输入手机号")
	{
		alert("手机号不得为空！");
	}
	else if(Verification.value=="获取验证码")
	{
		alert("验证码不得为空！");
	}
	else 
	{
		checkphone();
	}
	
	
	
}

/*--------------------------信纸点击事件--------------------------*/
function paper(){
	var big_stationery=document.getElementById("big_stationery");
	var envelope_out1=document.getElementById("envelope_out1");
	$(".envelope_out1").animate({opacity:"0"},1000);
	  setTimeout(function() {
                envelope_out1.style.zIndex="-1";
		big_stationery.style.zIndex="100";
            },
            1000)   
}





/*--------------------------弹窗--------------------------*/
function smallWindow(){
	var width=document.body.clientWidth;
	var height=document.body.clientHeight;
	var smallwindow=document.getElementById("small_window");
	var newPhoneNum=document.getElementById("middle1_text");
	var big=document.getElementById("big");
	var new_Num=document.getElementById("middle2_text");
	
	var big=document.getElementById("big");
	big.style.display="block";
	
	newPhoneNum.value="新手机号码";
	new_Num.value="教工号码";
	
	$("#page").addClass("body_background");
	$("#envelope").addClass("stationery_opacity");
	
	var x=width/2-402/2;
	var y=height/2-302/2;

	smallwindow.style.top=y+"px";
	smallwindow.style.left=x+"px";
	smallwindow.style.display="block";
	smallwindow.style.zIndex="500";
	
}

/*弹窗文本框（新手机号码&教工号码）*/
function newPhoneNum_onclick(){
	var New_PhoneNum=document.getElementById("middle1_text");
	New_PhoneNum.value="";
}

function newPhoneNum_onblur(){
	var New_PhoneNum=document.getElementById("middle1_text");
	if(New_PhoneNum.value==""){
			New_PhoneNum.value="新手机号码";
	}
}

function newNum_onclick(){   
	var New_Num=document.getElementById("middle2_text");
	New_Num.value="";
}

function newNum_onblur(){
	var New_Num=document.getElementById("middle2_text");
	if(New_Num.value==""){
			New_Num.value="教工号码";
	}
}

/*点击按钮时(取消&确定)*/

function sure_onclick(){
	
	var New_PhoneNum=document.getElementById("middle1_text");
	var New_Num=document.getElementById("middle2_text");
	
	var NumLen=New_Num.value.length;
	var phoneLen=New_PhoneNum.value.length;
	
	if(New_PhoneNum.value!="新手机号码"||New_Num.value!="教工号码")
	{
	if(phoneLen<11)
	{
		alert("请输入正确的手机号码！");
	}
	else if(phoneLen==11&&NumLen<7){
		alert("请输入正确的教工号");
	}
	else if(NumLen==7)
	{
		checksmallPane();
	}
	}
	else
	{
		if(New_PhoneNum.value=="新手机号码")
		{alert("请输入新手机号码！");}
		else if(New_Num.value=="教工号码")
		{alert("请输入教工号！");}
	}
	
}
function cancel_onclick(){
	var smallwindow=document.getElementById("small_window");
	var big=document.getElementById("big");
	big.style.display="none";
	
	$("#page").removeClass("body_background");
	$("#envelope").removeClass("stationery_opacity");
	
	smallwindow.style.display="none";
	smallwindow.style.zIndex="-200";
	
}

/*--------------------------判断手机号码--------------------------*/

function checkphone(){
	var tipPhone=document.getElementById("tips_phone");
	var tipVer=document.getElementById("tips_Verification");
	var a=0;
	/*alert(tipPhone.style.opacity);*/
	if(tipPhone.style.opacity=="1")
	{
		alert("请输入正确的手机号码！");
	}
	else 
	{
		new3.style.display="none";
		new4.style.display="block";

		$.post("xxx", {
					"academy": document.getElementById("span1").innerHTML,
					"grade":document.getElementById("span2").innerHTML,
					"Class":document.getElementById("span3").innerHTML,
					"phoneNum":document.getElementById("phoneNum").value,
					"Verification":document.getElementById("Verification").value
				}, function(data) {		
					document.getElementById("tips_phone").style.filter="alpha(opacity=100)";
					document.getElementById("tips_phone").style.opacity="1";/*手机号码错误出现的提示*/
					document.getElementById("tips_Verification").style.filter="alpha(opacity=100)";
			       document.getElementById("tips_Verification").style.opacity="1";/*验证码错误出现的提示*/
				}, "json");
	}
	
	}

function checksmallPane(){
	var New_PhoneNum=document.getElementById("middle1_text");
	var New_Num=document.getElementById("middle2_text");
	
	var NumLen=New_Num.value.length;
	var phoneLen=New_PhoneNum.value.length;
	
	for(var i=0;i<phoneLen;i++)
	{
		var c=New_PhoneNum.value.charAt(i);
		if(c<"0"||c>"9")
		{
			alert("请输入正确的手机号码！");
			return false;
		}
	}
	for(var k=0;k<NumLen;k++)
	{
		var t=New_Num.value.charAt(k);
		if(t<"0"||t>"9")
		{
			alert("请输入正确的教工号！");
			return false;
		}
	}
	var smallwindow=document.getElementById("small_window");
			var big=document.getElementById("big");
			big.style.display="none";
	
	$("#page").removeClass("body_background");
	$("#envelope").removeClass("stationery_opacity");
	
	smallwindow.style.display="none";
	smallwindow.style.zIndex="-200";
	
}

/*--------------------------enter--------------------------*/
function keyLogin(){
  if (event.keyCode==13)  
     document.getElementById("button_loginIn").click();  
}



















